--
-- 03/06/2012
-- demouc_m && dourle_a
--

--- Check if a string starts with a pattern
-- @param String string to check
-- @param Start pattern to match 
function string.starts(String,Start)
   return string.sub(String,1,string.len(Start))==Start
end

--- Check if a string ends with a pattern
-- @param String string to check
-- @param Start pattern to match 
function string.ends(String,End)
   return End=='' or string.sub(String,-string.len(End))==End
end

--- Remove characters from a string
-- @param str string to remove from
-- @param chr char to remove
function string.stripChars( str, chr )
   local s = ""
   for g in str:gmatch( "[^"..chr.."]" ) do
      s = s .. g
   end
   return s
end

--- Does string contains only lower case characters
-- @param text to check
function string.onlyLower(text)
   return (string.lower(text) == text)
end

--- String splitter
-- Also known as strtowortab()
-- @return An array of tokens
-- @param inputstr to split
-- @param sep string to use as delimiter
function string.split(inputstr, sep)
   if sep == nil then
      sep = "%s"
   end
   t={} ; i=1
   for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
      t[i] = str
      i = i + 1
   end
   return t
end